<template>
	<view class="page" :style="themeColor">
		<view class="flex align-stretch benben-position-layout flex address_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex align-center justify-between flex-sub address_fd0_0'>
				<view class='flex align-center address_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
					data-url="1">
					<text class='fu-iconfont2  address_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex align-center'>
					<text class='address_fd0_0_c1_c0'>地址管理</text>
				</view>
				<view class='flex align-center address_fd0_0_c2'>
				</view>
			</view>
		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---地址管理列表flex布局开始-->
		<view class="loading_css" v-if="!isShow">
			<u-loading size="36" color="#4177DD"></u-loading>
			<view class="loading_text">加载中</view>
		</view>
		<view v-else>
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout address_flex_1" v-for="(v, k) in list" :key="k" @tap.stop="selectAddress(v)">
				<view class='flex flex-direction flex-wrap align-stretch address_fd1_0'>
					<view class='flex flex-wrap align-center address_fd1_0_c0'>
						<text class='address_fd1_0_c0_c0' v-if="v.label_name">{{v.label_name}}</text>
						<text class='address_fd1_0_c0_c1'>{{v.name}}</text>
						<text class='address_fd1_0_c0_c2'>(</text>
						<text class='address_fd1_0_c0_c3' v-if="v.sex == 1">先生</text>
						<text class='address_fd1_0_c0_c3' v-if="v.sex == 2">女士</text>
						<text class='address_fd1_0_c0_c4'>)</text>
						<text class='address_fd1_0_c0_c5'>{{v.mobile}}</text>
					</view>
					<text class='address_fd1_0_c1'>{{v.province}}{{v.city}}{{v.district}}{{v.address}}</text>
				</view>
				<view class='flex align-center justify-between address_fd1_1'>
					<view class='flex flex-wrap align-center' @tap.stop="getDefault(v.is_default, v.address_id)">
						<image class='address_fd1_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"33.png"' v-if="v.is_default == 1"></image>
						<image class='address_fd1_1_c0_c0' mode="aspectFit" :src='STATIC_URL+"99.png"' v-else></image>
						<text class='address_fd1_1_c0_c1'>默认地址</text>
					</view>
					<view class='flex flex-wrap align-center'>
						<image class='address_fd1_1_c1_c0' :src='STATIC_URL+"97.png"'></image>
						<text class='address_fd1_1_c1_c1' @tap.stop="deleteInfo(v.address_id)">删除</text>
						<image class='address_fd1_1_c1_c2' :src='STATIC_URL+"98.png"'></image>
						<text class='address_fd1_1_c1_c3' @tap.stop="handleJumpDiy" data-type="navigateTo"
							:data-url="`/pages/wode/addAddress/addAddress?id=${v.address_id}&type=2`">编辑</text>
					</view>
				</view>
			</view>
			<view class="noData" v-if="list.length == 0">
				<image src="/static/empty/no.png"></image>
				<view>暂无地址列表~</view>
			</view>
		</view>
		<!---地址管理列表flex布局结束-->
		<view class="flex flex-direction align-center justify-center benben-position-layout flex address_flex_2">
			<button class='address_fd2_0' @tap.stop="handleJumpDiy" data-type="navigateTo"
				:data-url="`/pages/wode/addAddress/addAddress?id=0&type=1`">添加地址</button>

		</view>
		<view :style="{height: '88rpx'}"></view>
		<benben-popup v-model="popupShow1661425659576" :mask="true" mode='center'>
			<!---删除地址弹窗flex布局开始-->
			<view class="flex flex-direction flex-wrap align-center address_flex_3">
				<text class='address_fd3_0'>提示</text>
				<text class='address_fd3_1'>确定删除地址？</text>
				<view class='flex flex-wrap align-center address_fd3_2'>
					<button class='address_fd3_2_c0' @tap.stop="popupShow1661425659576=false">取消</button>
					<button class='address_fd3_2_c1' @tap.stop="delAddress">确定</button>
				</view>
			</view>
			<!---删除地址弹窗flex布局结束-->
		</benben-popup>

	</view>
</template>
<script>
	export default {
		components: {},

		data() {
			return {
				"popupShow1661425659576": false,
				"list": [],
				"address_id": "",
				"isShow": false
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.getList();
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 获取地址列表
			getList() {
				this.$api.post(global.apiUrls.post6436bb9841fa6, {
					
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.isShow = true;
						this.list = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 修改为默认收货地址  post63a6c85290736
			getDefault(is_default, address_id) {
				if (is_default == 1) return;
				this.$api.post(global.apiUrls.post6436bf07cb49d, {
					address_id: address_id
				}).then(res => {
					this.$message.info(res.data.msg);
					if (res.data.code == 1) {
						this.getList();
						uni.$emit('select_address', 1);
					}
				})
			},
			deleteInfo(address_id) {
				this.address_id = address_id;
				this.popupShow1661425659576 = true;
			},
			// 删除地址
			delAddress() {
				this.$api.post(global.apiUrls.post6436bef2f20af, {
					address_id: this.address_id
				}).then(res => {
					this.$message.info(res.data.msg);
					this.popupShow1661425659576 = false;
					if (res.data.code == 1) {
						this.getList();
						uni.$emit('select_address', 1);
					}
				})
			},
			selectAddress(v) {
				uni.$emit('select_address', v);
				uni.navigateBack();
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto !important;
	}

	.address_flex_0 {
		background: #fff;
		background-size: 100% !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.address_fd0_0_c2 {
		width: 180rpx;
	}

	.address_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.address_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}

	.address_fd0_0_c0 {
		width: 180rpx;
	}

	.address_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.address_flex_1 {
		border-top: 1px solid #F6F7F9;
		background: #fff;
		background-size: 100% !important;
		background-size: 100% auto !important;
		padding: 30rpx 32rpx 26rpx 32rpx;
		margin: 0rpx 0rpx 20rpx 0rpx;
	}

	.address_fd1_1_c1_c3 {
		line-height: 28rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}

	.address_fd1_1_c1_c2 {
		width: 30rpx;
		height: 30rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 12rpx 0rpx 67rpx;
	}

	.address_fd1_1_c1_c1 {
		line-height: 28rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}

	.address_fd1_1_c1_c0 {
		width: 30rpx;
		height: 30rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 12rpx 0rpx 0rpx;
	}

	.address_fd1_1_c0_c1 {
		line-height: 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}

	.address_fd1_1_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 14rpx 0rpx 0rpx;
	}

	.address_fd1_1 {
		padding: 26rpx 0rpx 0rpx 0rpx;
	}

	.address_fd1_0_c1 {
		line-height: 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}

	.address_fd1_0_c0_c5 {
		line-height: 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.address_fd1_0_c0_c4 {
		line-height: 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
	}

	.address_fd1_0_c0_c3 {
		line-height: 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
	}

	.address_fd1_0_c0_c2 {
		line-height: 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
	}

	.address_fd1_0_c0_c1 {
		line-height: 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
		max-width: 290rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.address_fd1_0_c0_c0 {
		background: #fff;
		background-size: 100% !important;
		line-height: 36rpx;
		font-size: 22rpx;
		font-weight: 400;
		color: #333;
		border: 1rpx solid #333;
		padding: 0rpx 10rpx 0rpx 10rpx;
		background-size: 100% auto !important;
		border-radius: 4rpx 4rpx 4rpx 4rpx;
		margin: 0rpx 14rpx 0rpx 0rpx;
	}

	.address_fd1_0_c0 {
		padding: 0rpx 0rpx 20rpx 0rpx;
	}

	.address_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 0rpx 0rpx 28rpx 0rpx;
	}

	.address_flex_2 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(32rpx + var(--window-bottom));
	}

	.address_fd2_0 {
		background: #fff;
		background-size: 100% !important;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #333;
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 400;
	}

	.address_flex_3 {
		background: #fff;
		background-size: 100% !important;
		margin: 0rpx 105rpx 0rpx 105rpx;
		background-size: #eee;
		border-radius: 25rpx 25rpx 25rpx 25rpx;
	}

	.address_fd3_2_c1 {
		background: transparent;
		background-size: 100% !important;
		line-height: 45rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: #4781f5;
		padding: 24rpx 103rpx 24rpx 99rpx;
	}

	.address_fd3_2_c0 {
		border-right: 1px solid #EEEEEE;
		background: transparent;
		background-size: 100% !important;
		line-height: 45rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		padding: 24rpx 103rpx 24rpx 103rpx;
	}

	.address_fd3_2 {
		border-top: 1px solid #eee;
	}

	.address_fd3_1 {
		font-size: 32rpx;
		font-weight: 400;
		line-height: 52rpx;
		color: #333333;
		margin: 0rpx 0rpx 38rpx 0rpx;
	}

	.address_fd3_0 {
		font-size: 32rpx;
		font-weight: 500;
		line-height: 32rpx;
		color: #333333;
		margin: 40rpx 0rpx 36rpx 0rpx;
	}
</style>
